package Kuaishou;

/**
 * @author leiwenkang <leiwenkang@kuaishou.com>
 * Created on 2022-02-09
 */
public class Test50ShaleXij {
    public static void main(String[] args) {
        double theta = 0.10757416345704807;
        double alpha = 2.1;
        double beta = 2.125088569468723;
        double weight = 0.10757416345704807;
        System.out.println(gij(theta, alpha, beta, weight));
    }

    private static final double MAX_RATIO = 1.0;

    /**
     * gij函数
     * @param theta
     * @param alpha
     * @param beta
     * @param weight
     * @return
     */
    public static double gij(double theta, double alpha, double beta, double weight) {
        if (Double.compare(alpha, Double.MAX_VALUE) == 0) {
            return MAX_RATIO;
        }
        double xij =  Math.max(0, theta * (1 + ((alpha - beta) / weight)));
        return Math.min(xij, MAX_RATIO);
    }
}
